package org.base.common.holder;

import org.springframework.core.NamedThreadLocal;

public class TimeZoneOffsetHolder {

    private static final ThreadLocal<Integer> timeZoneOffsetHolder =
            new NamedThreadLocal<>("TimeZoneOffset");

    public static Integer getOffset() {
        Integer offset = timeZoneOffsetHolder.get();
        if (offset == null) {
            offset = 0;
        }
        return offset;
    }

    public static void setOffset(Integer offset) {
        if (offset == null) {
            offset = 0;
        }
        timeZoneOffsetHolder.set(offset);
    }

    public static void remove() {
        timeZoneOffsetHolder.remove();
    }
}
